using Microsoft.VisualBasic.CompilerServices;
using SJVars;
using SJXmlP.XMLClasses;
using System;
using System.Reflection;
using System.Text;

namespace yW5Lib
{
	public class clsWordLog
	{
		private DateTime mvarDate;

		private int mvarWordCount;

		private int mvarTotalWordCount;

		private clsXml cXml;

		public DateTime LogDate
		{
			get
			{
				return mvarDate;
			}
			set
			{
				mvarDate = value;
			}
		}

		public int WordCount
		{
			get
			{
				return mvarWordCount;
			}
			set
			{
				mvarWordCount = value;
			}
		}

		public int TotalWordCount
		{
			get
			{
				return mvarTotalWordCount;
			}
			set
			{
				mvarTotalWordCount = value;
			}
		}

		public clsWordLog()
		{
			cXml = new clsXml();
		}

		public string DataAsXML()
		{
			string result = "";
			try
			{
				StringBuilder stringBuilder = new StringBuilder();
				string str = "\t\t";
				stringBuilder.AppendLine("\t<WC>");
				string value = str + cXml.EncloseDate(mvarDate, "<Date>", "</Date>");
				stringBuilder.AppendLine(value);
				value = str + cXml.EncloseInt(mvarWordCount, "<Count>", "</Count>");
				stringBuilder.AppendLine(value);
				value = str + cXml.EncloseInt(mvarTotalWordCount, "<TotalCount>", "</TotalCount>");
				stringBuilder.AppendLine(value);
				stringBuilder.AppendLine("\t</WC>");
				result = stringBuilder.ToString();
				return result;
			}
			catch (Exception ex)
			{
				ProjectData.SetProjectError(ex);
				Exception ex2 = ex;
				clsShared.cLog.AddAction(ex2, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
				return result;
			}
		}

		public void CreateFromXML(string XMLData)
		{
			try
			{
				Clear();
				mvarDate = cXml.ExtractDate(XMLData, "<Date>", "</Date>");
				mvarDate = mvarDate.Date;
				mvarWordCount = cXml.ExtractInt(XMLData, "<Count>", "</Count>");
				mvarTotalWordCount = cXml.ExtractInt(XMLData, "<TotalCount>", "</TotalCount>");
			}
			catch (Exception ex)
			{
				ProjectData.SetProjectError(ex);
				Exception ex2 = ex;
				clsShared.cLog.AddAction(ex2, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
			}
		}

		public void Clear()
		{
			mvarDate = DateTime.Now;
			mvarWordCount = 0;
			mvarTotalWordCount = 0;
		}
	}
}
